#ifndef TMCLIENTTHREAD_H
#define TMCLIENTTHREAD_H
//
#include <QThread>
#include <QTcpSocket>
#include <QTimer>
#include <QQueue>

class CTeaMakerMsg;
//
class CTMClientThread : public QThread
{
Q_OBJECT
public:
	CTMClientThread();
	
protected:
	void run();
	
private slots:
	// called when socket is connected:
	void connected();
	
	// called when socket is disconnected:
	void disconnected();
	
	// called when new data arrives:
	void readyRead();
	
	// tick method:
	void tick();
	
	// send a ping message:
	void sendPingMessage();
	
private:
	// socket we use toc onnect to the server instance:
	QTcpSocket *m_pSocket;
	// timer - schedules call to tick method.
	QTimer *m_pTickTimer;
	QTimer *m_pPingTimer;
	
	// queue of incoming messages:
	QQueue<CTeaMakerMsg*> m_incomingMessages;
	
	// queue of outgoing messages:
	QQueue<CTeaMakerMsg*> m_outgoingMessages;
	
};
#endif
